package main

import "fmt"

func main() {

	// 数组的定义方式

	var arrayVariable1 [10]int

	arrayVariable1[0] = 100
	arrayVariable1[3] = 200
	fmt.Println(arrayVariable1)

	var arrayVariable2 [5]int = [5]int{1, 2, 3, 4, 5}
	var arrayVariable2Len = len(arrayVariable2)

	for index := 0; index < arrayVariable2Len; index ++ {
		fmt.Printf("值为:%d, 地址为:%p", arrayVariable2[index], &arrayVariable2[index])
	}

	// 定义方式2
	arrayVariable3 := [...]int{1, 2, 3, 4, 5}
	fmt.Println(arrayVariable3)

	arrayVariable4 := [...]int{5: 100, 200: 300}
	fmt.Println(len(arrayVariable4))

	// 数组是值类型


	arrayVariable5 := [5]int{1, 2, 3, 4, 5}
	change1(arrayVariable5)


	arrayVariable6 := [5]int{1, 2, 3, 4, 5}

	for index, value := range arrayVariable6 {
		fmt.Printf("序列号是:%d-值是:%v-地址是:%p", index, value, &arrayVariable6[index])
	}

	// 二维数组
	var arrayVariable7 [4][2]int
	fmt.Println(arrayVariable7)

	var arrayVariable8 [3][2]int = [3][2]int{{1, 2}, {1, 2}, {1, 2}}
	fmt.Println(arrayVariable8)
}

func change1(array [5]int) {
	array[0] = 100
}

func change2(array *[5]int) {
	(*array)[0] = 100
}